grsunChooseWindow = {

};

/**
 * 组织机构选择
 */
grsunChooseWindow.chooseAgentWindow = {
	show : function(calls) {
		var me = this;
		// 回调函数
		me.callback = calls;
		parent.layer.open({
			title : '选择代理',
			type : 2,
			btn : [ '选入' ],
			area : [ '80%', '80%' ],
			content : rootpath + '/hhAgent/toTreeList.do',
			yes : function(index, layero) {
				var node = layero.find("iframe")[0].contentWindow.agentTable.datagrid('getSelected');
				if (node) {
					if (me.callback) {
						me.callback.call(me, node);
						parent.layer.close(index);
					}
				} else {
					parent.layer.msg('请选择一条数据！', {
						time : 1000,
						shade : 0.3
					})
				}
			}
		});
	}
}

/**
 * 字典选择
 */
grsunChooseWindow.dictChooseWindow = {
	show : function(calls) {
		var me = this;
		// 回调函数
		me.callback = calls;
		parent.layer.open({
			title : '选择字典',
			type : 2,
			btn : [ '选入' ],
			area : [ '50%', '80%' ],
			content : rootpath + '/dictionaries/toChoose.do',
			yes : function(index, layero) {
				var node = layero.find("iframe")[0].contentWindow.dictChooseTable.treegrid('getSelected');
				if (node) {
					if (me.callback) {
						me.callback.call(me, node);
						parent.layer.close(index);
					}
				} else {
					parent.layer.msg('请选择一条数据！', {
						time : 1000,
						shade : 0.3
					})
				}
			}
		});
	}
}

/**
 * 菜单选择框
 */
grsunChooseWindow.menuChooseWindow = {
	show : function(calls) {
		var me = this;
		// 回调函数
		me.callback = calls;
		parent.layer.open({
			title : '菜单',
			type : 2,
			btn : [ '选入' ],
			area : [ '50%', '80%' ],
			content : rootpath + '/menu/toChoose.do',
			yes : function(index, layero) {
				var node = layero.find("iframe")[0].contentWindow.menuChooseTable.treegrid('getSelected');
				if (node) {
					if (me.callback) {
						me.callback.call(me,node);
						parent.layer.close(index);
					}
				} else {
					parent.layer.msg('请选择一条数据！', {
						time : 1000,
						shade : 0.3
					})
				}
			}
		});
	}
}
/**
 * 菜单选择框Tree
 */
grsunChooseWindow.menuChooseTreeWindow = {
	show : function(window,calls,url) {
		var path = rootpath + '/menu/toChooseTree.do';
		if(url && url!=""){
			path = url;
		}
		var me = this;
		// 回调函数
		me.callback = calls;
		window.layer.open({
			title : '菜单选择',
			type : 2,
			btn : ['确定'],
			area : [ '270px', '80%' ],
			content : path,
			yes : function(index, layero) {
				var nodes = layero.find("iframe")[0].contentWindow.chooseMenuTree.tree('getChecked', ['checked','indeterminate']);
				if (me.callback) {
					me.callback.call(me,nodes);
					window.layer.close(index);
				}
			}
		});
	}
}

/**
 * 组织机构人员选择Tree
 */
grsunChooseWindow.chooseOrgInfoUserTreeWindow = {
	show : function(window,calls,url) {
		var path = rootpath + '/orginfo/toUserByOrgInfoChoose.do';
		if(url && url!=""){
			path = url;
		}
		var me = this;
		// 回调函数
		me.callback = calls;
		window.layer.open({
			title : '人员选择',
			type : 2,
			btn : ['确定'],
			area : [ '270px', '80%' ],
			content : path,
			yes : function(index, layero) {
				var node = layero.find("iframe")[0].contentWindow.chooseOrgInfoUserTree.tree('getSelected');
				if(node){
					console.log(node);
					if(node.iconCls){
						if (me.callback) {
							me.callback.call(me,node);
							window.layer.close(index);
						}
					}else{
						window.layer.msg('请选择人员信息！', {
							time : 1000,
							shade : 0.3
						})
					}
				}else{
					window.layer.msg('请选择一条数据！', {
						time : 1000,
						shade : 0.3
					})
				}
			}
		});
	}
}

/**
 * 组织机构选择Tree
 */
grsunChooseWindow.chooseOrgInfoTreeWindow = {
	show : function(window,calls,url) {
		var path = rootpath + '/orginfo/toOrgInfoTreeChoose.do';
		if(url && url!=""){
			path = url;
		}
		var me = this;
		// 回调函数
		me.callback = calls;
		window.layer.open({
			title : '组织机构选择',
			type : 2,
			btn : ['确定'],
			area : [ '270px', '80%' ],
			content : path,
			yes : function(index, layero) {
				var node = layero.find("iframe")[0].contentWindow.chooseOrgInfoUserTree.tree('getSelected');
				if(node){
					if (me.callback) {
						me.callback.call(me,node);
						window.layer.close(index);
					}
				}else{
					window.layer.msg('请选择一条数据！', {
						time : 1000,
						shade : 0.3
					})
				}
			}
		});
	}
}
grsunChooseWindow.chooseCityWindow = {
		show: function(calls, url) {
			var path = rootpath + '/hhCity/toChoose.do';
			if (url && url != "") {
				path = url;
			}
			var me = this;
			// 回调函数
			me.callback = calls;
			parent.layer.open({
				title : '城市父级选择',
				type : 2,
				btn : [ '确定' ],
				area : [ '50%', '80%' ],
				content : path,
				yes : function(index, layero) {
					var row = layero.find("iframe")[0].contentWindow.dataTable.datagrid('getSelected');
					if (row) {
						if (me.callback) {
							me.callback.call(me, row);
							parent.layer.close(index);
						}
					} else {
						parent.layer.msg('请选择一条数据！', {
							time : 1000,
							shade : 0.3
						})
					}
				}
			});
		}
	}
grsunChooseWindow.chooseParentNameWindow = {
		show: function(calls, url) {
			var path = rootpath + '/hhBusinessParent/toList.do';
			if (url && url != "") {
				path = url;
			}
			var me = this;
			// 回调函数
			me.callback = calls;
			parent.layer.open({
				title : '连锁店选择',
				type : 2,
				btn : [ '确定' ],
				area : [ '50%', '80%' ],
				content : path,
				yes : function(index, layero) {
					var row = layero.find("iframe")[0].contentWindow.dataTable.datagrid('getSelected');
					if (row) {
						if (me.callback) {
							me.callback.call(me, row);
							parent.layer.close(index);
						}
					} else {
						parent.layer.msg('请选择一条数据！', {
							time : 1000,
							shade : 0.3
						})
					}
				}
			});
		}
}